export function formatDate(date, formatter){
    let normalDate = new Date(date);
    if(normalDate !== 'Invalid Date'){
        let year = normalDate.getFullYear().toString();
        let month = normalDate.getMonth() + 1;
        month = month > 9 ? month.toString() : '0' + month.toString();
        let day = normalDate.getDate();
        day = day > 9 ? day.toString() : '0' + day.toString();

        let hours = normalDate.getHours();
        hours = hours > 9 ? hours.toString() : '0' + hours.toString();
        let minutes = normalDate.getMinutes();
        minutes = minutes > 9 ? minutes.toString() : '0' + minutes.toString();
        let seconds = normalDate.getSeconds();
        seconds = seconds > 9 ? seconds.toString() : '0' + seconds.toString();

        return formatter.replace('yyyy', year).replace('MM', month).replace('dd', day).replace('hh', hours).replace('mm', minutes).replace('ss',seconds);
    } else {
        throw new Error('Invalid date input:' + date);
    }
}